package controller.MenuActions;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import model.Constants;

/**
 * 
 * Deze klasse is verantwoordelijk voor de actie die geassocieerd is met het
 * Exit menu
 *
 */
public class ExitAction extends AbstractAction {

	private static final long serialVersionUID = 1L;

	@Override
	public void actionPerformed(ActionEvent e) {
		int dialogButton = JOptionPane.YES_NO_OPTION;
		int dialogResult = JOptionPane.showConfirmDialog(null,
				Constants.BEVESTIG, Constants.WAARSCHUWING, dialogButton);
		if (dialogResult == JOptionPane.YES_OPTION) {
			System.exit(0);
		}
	}

	public ExitAction(String name, String shortDescription, Integer mnemonic,
			KeyStroke key) {
		super(name, null);
		putValue(SHORT_DESCRIPTION, shortDescription);
		putValue(MNEMONIC_KEY, mnemonic);
		putValue(ACCELERATOR_KEY, key);
	}

}
